#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>

using namespace std;
const int N = 1010;

int n, m;
int h[N], e[N], ne[N], idx;
int w[N], inEdge[N];
int res[N];

void add(int a, int b){
    e[idx] = b;
    ne[idx] = h[a];
    h[a] = idx ++;
}


void solve(){
    idx = 0;
    memset(h, -1, sizeof h);
    memset(inEdge, 0, sizeof inEdge);
    
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i ++){
        scanf("%d", &w[i]);
    }

    for(int i = 0; i < m; i ++){
        int a, b;
        scanf("%d%d", &a, &b);
        add(a, b);
        inEdge[b] ++;
    }

    vector<int> nodes;
    for(int i = 1; i <= n; i ++){
        if(inEdge[i] == 0){
            nodes.push_back(i);
        }
    }




}

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    int T;
    scanf("%d", &T);
    while(T--){
        solve();
    }
    return 0;
}